(function($) {     
      
  $.fn.lin_blockFixed = function(options) {     
    // 处理默认参数   
    var opts = $.extend({}, $.fn.lin_blockFixed.defaults, options);     
    return this.each(function() {  
		var $this=$(this);
		var currentX=0,currentY=0;
		if(opts.reference!='')
		{
			var $reference=$(opts.reference);
			var offset=$reference.offset();
			currentX=offset.left;
			currentY=offset.top;
		}
		if(false)
		{
			$this.css('position','absolute');
			$.fn.lin_blockFixed.initIE6[opts.positionX+opts.positionY]($this,opts,currentX,currentY);	
			var timer=null;		
			$(window).scroll(function(){
				clearTimeout(timer);
				timer=setTimeout(function(){
					$.fn.lin_blockFixed.scrollEvent[opts.positionY]($this,opts,currentX,currentY);
				},100);
			});
		}else
			{
				$this.css('position','fixed');
				$.fn.lin_blockFixed.init[opts.positionX+opts.positionY]($this,opts,currentX,currentY);	
			}
    }); 
   
  };

  $.fn.lin_blockFixed.init=
  {
	lefttop:function($this,opts,currentX,currentY){
		$this.css({
			'top':currentY+opts.tempY,
			'left':currentX+opts.tempX
		});
	},
	righttop:function($this,opts,currentX,currentY){	
		$this.css({
			'top':currentY+opts.tempY,
			'right':currentX+opts.tempX
		});
	},
	leftbottom:function($this,opts,currentX,currentY){	
		$this.css({
			'left':currentX+opts.tempX,
			'bottom':opts.tempY
		});
	},
	rightbottom:function($this,opts,currentX,currentY){	
		$this.css({
			'right':currentX+opts.tempX,
			'bottom':opts.tempY
		});
	}				  
  }
  
  $.fn.lin_blockFixed.initIE6=
  {
	lefttop:function($this,opts,currentX,currentY){	
		$this.css({
			'top':currentY+opts.tempY,
			'left':currentX+opts.tempX
		});
	},
	righttop:function($this,opts,currentX,currentY){		
		$this.css({
			'top':currentY+opts.tempY,
			'right':currentX+opts.tempX
		});
	},
	leftbottom:function($this,opts,currentX,currentY){		
		var currentTop=$(window).height()-$this.outerHeight();
		$this.css({
			'left':currentX+opts.tempX,
			'top':currentTop-opts.tempY
		});
	},
	rightbottom:function($this,opts,currentX,currentY){
		var currentTop=$(window).height()-$this.outerHeight();
		$this.css({
			'right':currentX+opts.tempX,
			'top':currentTop-opts.tempY
		});
	}				  
  }  
  $.fn.lin_blockFixed.scrollEvent=
  {
	top:function($this,opts,currentX,currentY){
		var currentTop=$(window).scrollTop();
		if(!opts.isAnimate)
		{
			$this.css({
				'top':currentTop+opts.tempY+currentY
			});			
		}else
			{
				$this.stop().animate({"top":currentTop+opts.tempY+currentY},opts.speed);
			}
	},
	bottom:function($this,opts,currentX,currentY){
		var currentTop=$(window).height()-$this.outerHeight()+$(window).scrollTop();
		if(!opts.isAnimate)
		{
			$this.css({
				'top':currentTop-opts.tempY
			});			
		}else
			{
				$this.stop().animate({"top":currentTop-opts.tempY},opts.speed);
			}		
	}				  
  }  
 
  // 插件的defaults     
  $.fn.lin_blockFixed.defaults = {     
        positionX:'left',//X轴方向
		positionY:'top',//Y轴方向
		reference:'',//参照物
		isAnimate:true,//IE6下是否开启动画移动
		speed:720,//动画速度
		tempX:0,//临时X调整值
		tempY:0//临时Y调整值
  };     
// 闭包结束     
})(jQuery); 